package com.akuhome.resource.controller;

import com.akuhome.resource.entity.Classroom;
import com.akuhome.resource.service.entity.ClassroomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/classroom")
public class ClassroomController {
    @Autowired
    ClassroomService classroomService;

    @GetMapping
    public Object findAllClassroom(){
        return classroomService.findAllClassroom();
    }

    @PostMapping
    public Object insertClassroom(@Validated @RequestBody Classroom classroom, BindingResult bindingResult){
        return classroomService.insertClassroom(classroom);
    }

    @PutMapping
    public Object updateClassroom(@Validated @RequestBody Classroom classroom,BindingResult bindingResult){
        return classroomService.updateClassroom(classroom);
    }

    @DeleteMapping("/{classroomId}")
    public Object deleteClassroomById(@PathVariable Integer classroomId){
        return classroomService.deleteClassroomById(classroomId);
    }

}
